package com.ailesson.order.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ailesson.order.model.reply.OrderInfoReply;
import com.ailesson.order.model.req.OrderInfoReq;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.ailesson.order.service.OrderInfoService;
import com.ailesson.order.model.req.OrderInfoQueryReq;
import com.ailesson.common.reply.PageResult;
import com.ailesson.common.reply.R;



/**
 * 订单表 订单表
 *
 * @author mac
 * @email mac@gmail.com
 * @date 2024-10-12 21:32:50
 */
@Tag(name = "订单表 订单表模块")
@RestController
@RequestMapping("/admin/order/orderInfo")
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @Operation(summary = "列表")
    @Parameter(name = "params", in = ParameterIn.DEFAULT, description = "查询参数")
   // @RequiresPermissions("order:orderinfo:list")
    public R list(@RequestBody OrderInfoQueryReq params){
        PageResult page = orderInfoService.queryPage(params);

        return R.success(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @Operation(summary = "获取信息")
    @Parameter(name = "id",in = ParameterIn.PATH, description = "ID")
   // @RequiresPermissions("order:orderinfo:info")
    public R info(@PathVariable("id") Long id){
		OrderInfoReply orderInfo = orderInfoService.info(id);

         return R.success(orderInfo);
    }

    /**
     * 保存
     */
    @PostMapping("/add")
    @Operation(summary = "添加")
    @Parameter(name = "orderInfo",in = ParameterIn.QUERY, description = "添加信息")
    //@RequiresPermissions("order:orderinfo:save")
    public R add(@RequestBody OrderInfoReq orderInfo){
        return R.success(orderInfoService.add(orderInfo));
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @Operation(summary = "更新")
    @Parameter(name = "orderInfo",in = ParameterIn.QUERY, description = "更新信息")
    //@RequiresPermissions("order:orderinfo:update")
    public R update(@RequestBody OrderInfoReq orderInfo){
		orderInfoService.update(orderInfo);

        return R.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @Operation(summary = "删除")
    @Parameter(name = "ids",in = ParameterIn.QUERY, description = "删除主键ids")
    //@RequiresPermissions("order:orderinfo:delete")
    public R delete(@RequestBody Long[] ids){
		orderInfoService.removeByIds(Arrays.asList(ids));

        return R.success();
    }

}
